
import {createRouter,createWebHashHistory} from "vue-router";

const router = createRouter({
    history:createWebHashHistory(),
    routes:[
        {
            path:"/",
            redirect:"/Login"
        },
        {
            path:"/Login",
            component:()=>import("@/views/login.vue")
        },
        {
            name:"Admin",
            path:"/Admin",
            component:()=>import("@/views/Admin/index.vue"),
            children:[
                
            ]
        }
    ]
})


router.beforeEach((to,from,next)=>{
    if(to.path!="/" && to.path!="/Login"){
        if(!localStorage.getItem("username")){
            next("/Login");
        }
    }
    next();
})

export default router;